<?php

class IndexAction extends Action
{
       
    
    //显示
    public function showabc()
    {
        $model = M('User');
        $result = $model->select();
        $this->display('abc');
    }

    //增
    public function insert()
    {
        $data['name'] = $_REQUEST['name'];
        $data['sex'] = $_REQUEST['sex'];
        $data['name'] = $_REQUEST['name'];
        $model = M('User');
        $result = $model->add($data);
        if ($result) {
            echo 'ok';
        }
      
    $this->display('index'); 
    }
    //删delete
    public function delete()
    {

      // $data['name'] = $_REQUEST['name'];
      // $data['sex'] = $_REQUEST['sex'];
     //  $data['name'] = $_REQUEST['name'];
       // $data['name'] = "0011";
        $model = M('User');
        //if($_REQUEST['name'])  delete($data);
         $map['id']=array('in','61,62');
        $result = $model->where($map)->delete();
        dump('$result');
        if ($result) {
            echo 'ok';
        }
        //$this->display('index');
    }

    //秀表数据show
    public function show()
    {

        $model = M('User');
        // $result1=$model->query('select * from __TABLE__ ');
         //   $this->assign($result1);
         $sql='select * from user';
        $result1 = $model->query($sql);
        $this->assign('name',$result1);
       // foreach($result1){
      //      
       // }
        //dump ($result1);die();
        $this->display();
     //  for( $i=0;$i<count($result1);$i++)
//    {
//    //echo 'result1['.$i.']='.$result1[$i].'<br>';
//      echo "$result1[$i]'<br>'";
//    }
//        print ($result1);
//        echo $result1;
        //$this->display('index');
    }

    //改change
    public function change()
    {

       // $userInfo = array('name' => '123456789');
      //  $db->update("user", $userInfo, "id = 2");
       // dump($user_db->printMessage());
        //$model->where('id =27')->update('name=27name');
     //   $this->display('index');
     
        $model = M('User');
        //if($_REQUEST['name'])  delete($data);
        $data['name']='change';
        $result = $model->where('id=58')->data($data)->save();
        if ($result) {
            echo 'ok';
    
    }

}
}